import {Feed} from "../sql/domin";

export function copyObject<T>(data:any){
    let json = JSON.stringify(data)
    let datas : Partial<T> = JSON.parse(json)
    return datas as T
}

//@ts-ignore
export function AuditToFeed(feed:Feed):Feed{
    //@ts-ignore
    delete feed.optimisticLock
    //@ts-ignore
    feed.optionMonth = feed.optionDateForMonth
    //@ts-ignore
    delete feed.optionDateForMonth
    //@ts-ignore
    feed.reloadDay = feed.reloadingDate
    //@ts-ignore
    delete feed.reloadingDate
    //@ts-ignore
    feed.nextReloadDay = feed.nextReloadingDate
    //@ts-ignore
    delete feed.nextReloadingDate
    return feed
}

export function FeedToAudit(feed:Feed):Feed{
    //@ts-ignore
    feed.optionDateForMonth = feed.optionMonth
    //@ts-ignore
    feed.reloadingDate = feed.reloadDay
    //@ts-ignore
    feed.nextReloadingDate = feed.nextReloadDay
    return feed
}
